Skip to content

fix: noWatch sync no longer prevents SSH injection#3205

Open
raman1236 wants to merge 1 commit intodevspace-sh:mainfrom
raman1236:fix/nowatch-prevents-ssh
Open

fix: noWatch sync no longer prevents SSH injection#3205
raman1236 wants to merge 1 commit intodevspace-sh:mainfrom
raman1236:fix/nowatch-prevents-ssh

Conversation

@raman1236
Copy link
Copy Markdown

Problem

When a sync config has noWatch: true, SSH server injection never starts. The SSH section in devspace.yaml is completely ignored when any sync entry has noWatch: true.

Root Cause

The dev mode starts services in sequence: sync → port forwarding → SSH. SSH only starts after sync initialization completes (<-syncDone).

When noWatch: true:

  1. StartSync creates a cancelable context for that sync entry
  2. The sync goroutine starts, completes initial sync, and returns
  3. defer cancel() fires, cancelling the context
  4. Meanwhile, startWithWait() had registered a RestartOnError goroutine via parent.Go() that listens on ctx.Context().Done()
  5. The context cancellation triggers this handler, which calls syncStop()parent.Kill(nil)
  6. The parent tomb enters a dying state
  7. SSH (which starts after <-syncDone) either cannot start or is immediately terminated because the tomb is dying

Fix

Set RestartOnError to false when NoWatch is true. A one-shot sync has no need for restart-on-error handling since it completes after initial sync. This prevents the restart handler goroutine from being registered, which in turn prevents it from killing the parent tomb when the cancelled context fires.

Change

In pkg/devspace/services/sync/sync.go, startSync():

// Before:
RestartOnError: true,

// After:
RestartOnError: !syncConfig.NoWatch,

Fixes #3005

When a sync config has noWatch: true, the sync goroutine completes
after initial sync and defer-cancels its context. This triggers the
RestartOnError handler which calls parent.Kill(nil), putting the
tomb in a dying state. Since SSH starts after sync completes (it
waits on <-syncDone), the killed tomb prevents SSH from starting.

Fix: set RestartOnError to false when NoWatch is true. A one-shot
sync has no need for restart-on-error handling, and this prevents
the handler from killing the parent tomb on context cancellation.

Fixes devspace-sh#3005
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 5, 2026

Deploy Preview for devspace-docs canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit dbf7b52
🔍 Latest deploy log https://app.netlify.com/projects/devspace-docs/deploys/69d2df459e787a000842fa7e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding noWatch: true prevents ssh injection

2 participants